#ifndef OSG_ADAPTER_H
#define OSG_ADAPTER_H
#include <qcolor.h>
#include <qstring.h>
#include <qtextstream.h>
#include <osg/Vec3f.h>
#include <osg/Vec4f.h>
#include <osg/Node.h>
#include <osgearth/GeoData.h>
#include <osgearth/SpatialReference.h>
#include "SDKCorePrivate.h"

inline QColor osgVec4ToQColor(const osg::Vec4f& v4)
{
	return QColor(v4.r(),v4.g(),v4.b(),v4.a());
}

inline osg::Vec4f qColorToOsgVec4(const QColor& color)
{
	return osg::Vec4f(color.redF(),color.greenF(),color.blueF(),color.alphaF());
}

inline osg::Vec3f pointToOsgVec3(int x,int y)
{
	return osg::Vec3f(x,y,0);
}

inline QString osgVec3fToString(const osg::Vec3f& vec)
{
	return QString("%1 %2 %3").arg(vec.x()).arg(vec.y()).arg(vec.z());
}

osg::Vec3f stringToOsgVec3f(const QString& string);

struct OsgNodeTwinkleCallback : public osg::NodeCallback 
{
	void operator()(osg::Node* n,osg::NodeVisitor* nv) 
	{
		static unsigned long i = 0;
		i++;
		if(i%100<50)
			traverse(n,nv);
	}
};

osgEarth::GeoPoint stringToGeoPoint(const QString& string);
QString geopointToString(const osgEarth::GeoPoint& point);

inline bool stringToBoolean(const QString& string)
{
    return string == "True" || string == "true" || string == "1";
}

#endif
